package org.deadline.service.config;

import java.util.List;
import org.deadline.model.config.JobTitle;
import org.deadline.repository.config.JobTitleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class JobTitleServiceImpl implements JobTitleService {

	@Autowired
    JobTitleRepository jobTitleRepository;

	public long countAllJobTitles() {
        return jobTitleRepository.count();
    }

	public void deleteJobTitle(JobTitle jobTitle) {
        jobTitleRepository.delete(jobTitle);
    }

	public JobTitle findJobTitle(Long id) {
        return jobTitleRepository.findOne(id);
    }

	public List<JobTitle> findAllJobTitles() {
        return jobTitleRepository.findAll();
    }

	public List<JobTitle> findJobTitleEntries(int firstResult, int maxResults) {
        return jobTitleRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveJobTitle(JobTitle jobTitle) {
        jobTitleRepository.save(jobTitle);
    }

	public JobTitle updateJobTitle(JobTitle jobTitle) {
        return jobTitleRepository.save(jobTitle);
    }
}
